/*
 *
函数指针的具体应用场景：

10 2
+:12
-:8
*:20
/:5
fun_arith: 12 

 */
#include<stdio.h>

int add(int a, int b){return a+b;}
int sub(int a, int b){return a-b;}
int mul(int a, int b){return a*b;}
int div(int a, int b){return a/b;}
double f(double a, double b){return a+b;}
int fun_arith(int a, int b, int (*p)(int, int)){ return p(a,b);}
int main(){
	int m, n;
	scanf("%d%d",&m, &n);

	int (*p)(int,int);

	p=add;
	printf("+:%d\n",p(m,n));
	p=sub;
	printf("-:%d\n",p(m,n));
	p=mul;
	printf("*:%d\n",p(m,n));
	p=div;
	printf("/:%d\n",p(m,n));

	//由于类型不一致，编译有问题 ERROR
	//p=f;
	
	//更常见的用法，是将函数指针作为一个变量使用
	printf("fun_arith: %d \n",fun_arith(m, n, add));

	return 0;
}
